<% /* $Id: submit.jsp 132 2011-08-26 10:23:42Z altdotua@gmail.com $ */ %>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ include file="../header.jsp" %>

<h1 align="center"><%= bundle.getString("W_SUBMIT_SOLUTION") %></h1>

<div align="center">
	<form action="<%= Linker.link("submissions") %>" method="post">
		<input type="hidden" name="action" value="submit">
		<input type="hidden" name="contestId" value="<%= contest.getId() %>">
		<input type="hidden" name="return" value="<%= Linker.link("contests/submissions.jsp?contest_id=" + contest.getId()) %>">
		<table class="b0">
			<tr>
				<td class="b0"><%= bundle.getString("W_USER") %></td>
				<td class="b0">
					<select name="userId">
					<%
						List<UserEntry> users = UsersModel.getAllEntries();
						for (UserEntry cuser : users)
						{
					%>
						<option value="<%= cuser.getId() %>"><%= cuser.getUsername() %>
					<%
 						}
					%>
					</select>
				</td>
			</tr>

			<tr class="b0">
				<td class="b0"><%= bundle.getString("W_PROBLEM") %></td>
				<td class="b0">
					<select name="problemId">
					<%
						HashMap<String, Object> map = new HashMap<String, Object>();
						map.put("contestId", contest.getId());
						if (!user.isAdmin())
						{
							map.put("active", true);
							map.put("visible", true);
						}
						List<ContestProblemEntry> problems = ContestProblemsModel.getEntries(map);
						String problemId = request.getParameter("problem_id");
						for (ContestProblemEntry problem : problems)
						{
					%>
					<option value="<%= problem.getId() %>" <%= problem.getId().toString().equals(problemId) ? " selected=\"selected\"" : "" %>><%= problem %> 
					<%
 						}
 					%>
					</select>
				</td>
			</tr>
			<tr>
				<td class="b0"><%= bundle.getString("W_LANGUAGE") %></td>
				<td class="b0">
					<select name="languageId">
					<%
						List<LanguageEntry> languages = LanguagesModel.getAllEntries();
						String languageId = request.getParameter("language_id");
						for (LanguageEntry language : languages)
						{
					%>
						<option value="<%=language.getId()%>" <%= language.getId().toString().equals(language) || language.getId().toString().equals(request.getSession().getAttribute("language")) ? " selected=\"selected\"" : "" %>><%=language%>
					<%
 						}
					%>
					</select>
				</td>
			</tr>
			<tr class="b0">
				<td colspan="2" class="b0"><textarea name="sourceCode" rows="30" cols="80"></textarea></td>
			</tr>
			<%
				Boolean allowFirstTest = contest.getAllowFirstTestOnly();
				if (allowFirstTest == null || Boolean.TRUE.equals(allowFirstTest))
				{
			%>
			<tr class="b0">
				<td colspan="2" class="b0">
					<input type="checkbox" name="fFirstTestOnly" checked="checked">
					<%= bundle.getString("W_FIRST_TEST_ONLY") %>?
				</td>
			</tr>
			<%
				}
			%>
			<tr class="b0">
				<td colspan="2" align="center" class="b0"><input type="submit" value="<%= bundle.getString("W_SUBMIT") %>"></td>
			</tr>
		</table>
	</form>
</div>

<%@ include file="../footer.jsp" %>